import java.util.Properties;

public class Main {
    public static void main(String[] args) {
//        Factory bmwFactory = new BMWFactory();
//        Product bmwCar = bmwFactory.createCar();
//        bmwCar.run();

        try{
            Properties properties=new Properties();
            properties.load(Main.class.getResourceAsStream("/carName.properties"));
            String s=properties.getProperty("carName");
            if(s.equals("BMW")){
                Factory bmwFactory = new BMWFactory();
                Product bmwCar = bmwFactory.createCar();
                Product proxy=ProxyUtil.createProxy(bmwCar);
                proxy.run();
                proxy.stop();
            }
            else if(s.equals("Benz")){
                Factory BenzFactory = new BenzFactory();
                Product BenzCar = BenzFactory.createCar();
                Product proxy=ProxyUtil.createProxy(BenzCar);
                proxy.run();
                proxy.stop();
            }
        }
        catch(Exception e) {
            System.out.println(e.getMessage());
        }
    }
}